<!DOCTYPE html>
<html>
<head><meta name="generator" content="Hexo 3.8.0">
  <meta charset="utf-8">
  

  
  <title>2018 年计算机科学与工程学院新生赛 #1 | Tootal World</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="ACM新生赛总结，加油！ A326. CC玩游戏只需判断$T+\sum_{i=1}^nA[i]\le K$是否成立即可。">
<meta name="keywords" content="ACM">
<meta property="og:type" content="article">
<meta property="og:title" content="2018 年计算机科学与工程学院新生赛 #1">
<meta property="og:url" content="http://tootal.xyz/2018/12/01/2018-年计算机科学与工程学院新生赛-1/index.html">
<meta property="og:site_name" content="Tootal World">
<meta property="og:description" content="ACM新生赛总结，加油！ A326. CC玩游戏只需判断$T+\sum_{i=1}^nA[i]\le K$是否成立即可。">
<meta property="og:locale" content="default">
<meta property="og:updated_time" content="2018-12-19T09:30:37.843Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="2018 年计算机科学与工程学院新生赛 #1">
<meta name="twitter:description" content="ACM新生赛总结，加油！ A326. CC玩游戏只需判断$T+\sum_{i=1}^nA[i]\le K$是否成立即可。">
  
    <link rel="alternate" href="../../../../atom.xml" title="Tootal World" type="application/atom+xml">
  
  
    <link rel="icon" href="http://tootal.xyz/favicon.png">
  
  
    <link href="http://fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  <link rel="stylesheet" href="../../../../css/style.css">
</head>
</html>
<body>
  <div id="container">
    <div id="wrap">
      <header id="header">
  <div id="banner"></div>
  <div id="header-outer" class="outer">
    <div id="header-title" class="inner">
      <h1 id="logo-wrap">
        <a href="../../../../index.html" id="logo">Tootal World</a>
      </h1>
      
        <h2 id="subtitle-wrap">
          <a href="../../../../index.html" id="subtitle">在时光的流逝中，逐渐成为更好的自己。</a>
        </h2>
      
    </div>
    <div id="header-inner" class="inner">
      <nav id="main-nav">
        <a id="main-nav-toggle" class="nav-icon"></a>
        
          <a class="main-nav-link" href="../../../../index.html">Home</a>
        
          <a class="main-nav-link" href="../../../../archives">Archives</a>
        
      </nav>
      <nav id="sub-nav">
        
          <a id="nav-rss-link" class="nav-icon" href="../../../../atom.xml" title="RSS Feed"></a>
        
        <a id="nav-search-btn" class="nav-icon" title="Search"></a>
      </nav>
      <div id="search-form-wrap">
		<!--below use google search-->
        <!--%- search_form({button: '&#xF002;'}) %-->
		<!--below use baidu search-->
		 <!--form action="http://www.baidu.com/baidu" method="get" accept-charset="utf-8" class="search-form">
          <input type="search" name="word" maxlength="20" class="search-form-input" placeholder="Search">
          <input type="submit" value="" class="search-form-submit">
          <input name=tn type=hidden value="bds">
          <input name=cl type=hidden value="3">
          <input name=ct type=hidden value="2097152">
          <input type="hidden" name="si" value="tootal.xyz">
        </form-->
		<!--below use swiftype search-->
		<!--input type="search" name="word" maxlength="20" class="st-default-search-input" placeholder="Search"-->
		<input type="text" class="st-default-search-input">
		<script type="text/javascript">
			(function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
			(w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
			e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
			})(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');
			_st('install','PwDt_XJKCzu2LMzrR5qV','2.0.0');
		</script>
      </div>
    </div>
  </div>
</header>
      <div class="outer">
        <section id="main"><article id="post-2018-年计算机科学与工程学院新生赛-1" class="article article-type-post" itemscope="" itemprop="blogPost">
  <div class="article-meta">
    <a href="index.html" class="article-date">
  <time datetime="2018-12-01T15:35:37.000Z" itemprop="datePublished">2018-12-01</time>
</a>
    
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      2018 年计算机科学与工程学院新生赛 #1
    </h1>
  

      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <p>ACM新生赛总结，加油！</p>
<h1 id="A"><a href="index.html#A" class="headerlink" title="A"></a>A</h1><p><a href="https://scut.online/p/326" target="_blank" rel="noopener">326. CC玩游戏</a><br>只需判断$T+\sum_{i=1}^nA[i]\le K$是否成立即可。<br><a id="more"></a><br><figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> n,t,k;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;n&gt;&gt;t&gt;&gt;k;</span><br><span class="line">	<span class="keyword">int</span> sum=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="keyword">int</span> x;</span><br><span class="line">		<span class="built_in">cin</span>&gt;&gt;x;</span><br><span class="line">		sum+=x;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(t+sum&lt;=k)<span class="built_in">cout</span>&lt;&lt;<span class="string">"CCHandsome!\n"</span>;</span><br><span class="line">	<span class="keyword">else</span> <span class="built_in">cout</span>&lt;&lt;<span class="string">"PoorCC!"</span>;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure></p>
<h1 id="B"><a href="index.html#B" class="headerlink" title="B"></a>B</h1><p><a href="https://scut.online/p/327" target="_blank" rel="noopener">327. CC的木棍</a><br>推出答案的函数表达式，容易看出单调性。<br>二分求函数零点。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">double</span> x,y,c;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">double</span> eps=<span class="number">1e-9</span>;</span><br><span class="line"><span class="function"><span class="keyword">double</span> <span class="title">f</span><span class="params">(<span class="keyword">double</span> m)</span></span>&#123;</span><br><span class="line">	<span class="keyword">double</span> tx=(x*x-m*m),ty=(y*y-m*m);</span><br><span class="line">	<span class="keyword">double</span> ans=tx*ty-c*c*(tx+ty+<span class="number">2</span>*<span class="built_in">sqrt</span>(tx*ty));</span><br><span class="line">	<span class="keyword">return</span> ans;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;x&gt;&gt;y&gt;&gt;c;</span><br><span class="line">	<span class="keyword">double</span> l=<span class="number">0</span>,r=min(x,y),mid;</span><br><span class="line">	<span class="keyword">int</span> flag=(f(l)&gt;<span class="number">0</span>)?<span class="number">1</span>:<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">while</span>(<span class="number">1</span>)&#123;</span><br><span class="line">		mid=(l+r)/<span class="number">2.0</span>;</span><br><span class="line">		<span class="keyword">double</span> temp=f(mid);</span><br><span class="line">		<span class="keyword">if</span>(<span class="built_in">fabs</span>(l-r)&lt;eps)<span class="keyword">break</span>;</span><br><span class="line">		<span class="keyword">if</span>(<span class="built_in">fabs</span>(temp)&lt;eps)<span class="keyword">break</span>;</span><br><span class="line">		<span class="keyword">else</span> <span class="keyword">if</span>(temp&gt;<span class="number">0</span>)&#123;</span><br><span class="line">			<span class="keyword">if</span>(flag)l=mid;</span><br><span class="line">			<span class="keyword">else</span> r=mid;</span><br><span class="line">		&#125;<span class="keyword">else</span> <span class="keyword">if</span>(temp&lt;<span class="number">0</span>)&#123;</span><br><span class="line">			<span class="keyword">if</span>(flag)r=mid;</span><br><span class="line">			<span class="keyword">else</span> l=mid;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"%.8lf\n"</span>,mid);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="C"><a href="index.html#C" class="headerlink" title="C"></a>C</h1><p><a href="https://scut.online/p/328" target="_blank" rel="noopener">328. CC的秘密</a><br>先预处理出[1000,9999]范围内所有的素数。<br>然后写大暴力，把A在12步变动以内所有的数处理一遍，看是否有B。<br>一开始我也是不确定多少步，通过写暴力数据测试，可以得知。<br>范围内任意一个素数都可以在10步以内修改得到任意另一个素数。<br>因此这题的Impossible是不可能出现的情况！<br><del>BFS完全没想到啊</del></p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">int</span> check[<span class="number">10005</span>],can[<span class="number">15</span>][<span class="number">10005</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("input.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("output.txt","w",stdout);</span></span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1000</span>;i&lt;=<span class="number">9999</span>;i++)&#123;</span><br><span class="line">		<span class="keyword">int</span> f=<span class="number">1</span>;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">2</span>;j&lt;=<span class="keyword">int</span>(<span class="built_in">sqrt</span>(i))+<span class="number">1</span>;j++)&#123;</span><br><span class="line">			<span class="keyword">if</span>(i%j==<span class="number">0</span>)&#123;</span><br><span class="line">				f=<span class="number">0</span>;</span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(f)check[i]=<span class="number">1</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">int</span> t;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;t;</span><br><span class="line">	<span class="keyword">while</span>(t--)&#123;</span><br><span class="line">		<span class="keyword">int</span> a,b;</span><br><span class="line">		<span class="built_in">cin</span>&gt;&gt;a&gt;&gt;b;</span><br><span class="line">		<span class="keyword">if</span>(a==b)&#123;</span><br><span class="line">			<span class="built_in">cout</span>&lt;&lt;<span class="string">"0\n"</span>;</span><br><span class="line">			<span class="keyword">continue</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="built_in">memset</span>(can,<span class="number">0</span>,<span class="keyword">sizeof</span>(can));</span><br><span class="line">		can[<span class="number">0</span>][a]=<span class="number">1</span>;</span><br><span class="line">		<span class="keyword">int</span> times=<span class="number">0</span>;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=<span class="number">12</span>;i++)&#123;</span><br><span class="line">			<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">1000</span>;j&lt;=<span class="number">9999</span>;j++)&#123;</span><br><span class="line">				<span class="keyword">if</span>(can[i<span class="number">-1</span>][j])&#123;</span><br><span class="line">					<span class="keyword">int</span> a1=j/<span class="number">1000</span>,a2=(j/<span class="number">100</span>)%<span class="number">10</span>,a3=(j%<span class="number">100</span>)/<span class="number">10</span>,a4=(j%<span class="number">10</span>);</span><br><span class="line">					<span class="keyword">for</span>(<span class="keyword">int</span> k=<span class="number">1</span>;k&lt;=<span class="number">9</span>;k++)&#123;</span><br><span class="line">						<span class="keyword">if</span>(k==a1)<span class="keyword">continue</span>;</span><br><span class="line">						<span class="keyword">int</span> temp=k*<span class="number">1000</span>+a2*<span class="number">100</span>+a3*<span class="number">10</span>+a4;</span><br><span class="line">						<span class="keyword">if</span>(check[temp])&#123;</span><br><span class="line">							can[i][temp]=<span class="number">1</span>;</span><br><span class="line">						&#125;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="keyword">for</span>(<span class="keyword">int</span> k=<span class="number">0</span>;k&lt;=<span class="number">9</span>;k++)&#123;</span><br><span class="line">						<span class="keyword">if</span>(k==a2)<span class="keyword">continue</span>;</span><br><span class="line">						<span class="keyword">int</span> temp=a1*<span class="number">1000</span>+k*<span class="number">100</span>+a3*<span class="number">10</span>+a4;</span><br><span class="line">						<span class="keyword">if</span>(check[temp])&#123;</span><br><span class="line">							can[i][temp]=<span class="number">1</span>;</span><br><span class="line">						&#125;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="keyword">for</span>(<span class="keyword">int</span> k=<span class="number">0</span>;k&lt;=<span class="number">9</span>;k++)&#123;</span><br><span class="line">						<span class="keyword">if</span>(k==a3)<span class="keyword">continue</span>;</span><br><span class="line">						<span class="keyword">int</span> temp=a1*<span class="number">1000</span>+a2*<span class="number">100</span>+k*<span class="number">10</span>+a4;</span><br><span class="line">						<span class="keyword">if</span>(check[temp])&#123;</span><br><span class="line">							can[i][temp]=<span class="number">1</span>;</span><br><span class="line">						&#125;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="keyword">for</span>(<span class="keyword">int</span> k=<span class="number">0</span>;k&lt;=<span class="number">9</span>;k++)&#123;</span><br><span class="line">						<span class="keyword">if</span>(k==a4)<span class="keyword">continue</span>;</span><br><span class="line">						<span class="keyword">int</span> temp=a1*<span class="number">1000</span>+a2*<span class="number">100</span>+a3*<span class="number">10</span>+k;</span><br><span class="line">						<span class="keyword">if</span>(check[temp])&#123;</span><br><span class="line">							can[i][temp]=<span class="number">1</span>;</span><br><span class="line">						&#125;</span><br><span class="line">					&#125;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">if</span>(can[i][b])&#123;</span><br><span class="line">					times=i;</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span>(times)<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(times)<span class="built_in">cout</span>&lt;&lt;times&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">		<span class="keyword">else</span> <span class="built_in">cout</span>&lt;&lt;<span class="string">"Impossible"</span>&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>附上当时考场上写的数据生成程序。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">int</span> check[<span class="number">10005</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	freopen(<span class="string">"input.txt"</span>,<span class="string">"w"</span>,<span class="built_in">stdout</span>);</span><br><span class="line">	<span class="built_in">cout</span>&lt;&lt;<span class="string">"100\n"</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1000</span>;i&lt;=<span class="number">9999</span>;i++)&#123;</span><br><span class="line">		<span class="keyword">int</span> flag=<span class="number">1</span>;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">2</span>;j&lt;<span class="keyword">int</span>(<span class="built_in">sqrt</span>(i))+<span class="number">1</span>;j++)&#123;</span><br><span class="line">			<span class="keyword">if</span>(i%j==<span class="number">0</span>)&#123;</span><br><span class="line">				flag=<span class="number">0</span>;</span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(flag)&#123;</span><br><span class="line">			<span class="comment">//printf("1009 %d\n",i);</span></span><br><span class="line">			check[i]=<span class="number">1</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">int</span> count=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1000</span>;i&lt;=<span class="number">9999</span>;i++)&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">1000</span>;j&lt;=<span class="number">9999</span>;j++)&#123;</span><br><span class="line">			<span class="keyword">if</span>(check[i]&amp;&amp;check[j])&#123;</span><br><span class="line">				<span class="built_in">printf</span>(<span class="string">"%d %d\n"</span>,i,j);</span><br><span class="line">				count++;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">cout</span>&lt;&lt;count&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="D"><a href="index.html#D" class="headerlink" title="D"></a>D</h1><p><a href="https://scut.online/p/329" target="_blank" rel="noopener">329. CC的画板</a></p>
<h1 id="E"><a href="index.html#E" class="headerlink" title="E"></a>E</h1><p><a href="https://scut.online/p/330" target="_blank" rel="noopener">330. CC锤小兵</a><br>当时没想到前缀和+后缀和的做法。<br>用了一种类似数位dp的方法。<br>f[i][j][0]表示前i-1个数第j位是否有0<br>f[i][j][1]表示前i-1个数第j位是否有1<br>g[i][j]类似表示第i个数后的数。<br>感觉和前缀后缀类似，但是写法要麻烦一点。<br>这样可以处理位与和位或。<br>由于异或的逆元是本身。<br>故可以先把所有数异或一下，再异或a[i]就可以得到除a[i]外所有数异或的结果。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> N=<span class="number">100005</span>;</span><br><span class="line"><span class="keyword">int</span> a[N],p[N],Xor,f[N][<span class="number">12</span>][<span class="number">2</span>],g[N][<span class="number">12</span>][<span class="number">2</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//freopen("input.txt","r",stdin);</span></span><br><span class="line">	<span class="comment">//freopen("output.txt","w",stdout);</span></span><br><span class="line">	<span class="keyword">int</span> n,m;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;n&gt;&gt;m;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="built_in">cin</span>&gt;&gt;a[i];</span><br><span class="line">	&#125;</span><br><span class="line">	Xor=a[<span class="number">1</span>];</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">2</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		Xor=Xor^a[i];</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">		<span class="built_in">cin</span>&gt;&gt;p[i];</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">2</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;=<span class="number">10</span>;j++)&#123;</span><br><span class="line">			f[i][j][<span class="number">0</span>]=f[i][j][<span class="number">0</span>]||f[i<span class="number">-1</span>][j][<span class="number">0</span>]||(((a[i<span class="number">-1</span>]&gt;&gt;j)&amp;<span class="number">1</span>)==<span class="number">0</span>);</span><br><span class="line">			f[i][j][<span class="number">1</span>]=f[i][j][<span class="number">1</span>]||f[i<span class="number">-1</span>][j][<span class="number">1</span>]||(((a[i<span class="number">-1</span>]&gt;&gt;j)&amp;<span class="number">1</span>)==<span class="number">1</span>);</span><br><span class="line">			<span class="comment">//printf("f[%d][%d][0]=%d,f[%d][%d][1]=%d\n",i,j,f[i][j][0],i,j,f[i][j][1]);</span></span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=n<span class="number">-1</span>;i&gt;=<span class="number">1</span>;i--)&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;=<span class="number">10</span>;j++)&#123;</span><br><span class="line">			<span class="comment">//printf("(a[%d]&gt;&gt;%d)&amp;1=%d\n",i+1,j,(a[i+1]&gt;&gt;j)&amp;1);</span></span><br><span class="line">			g[i][j][<span class="number">0</span>]=g[i][j][<span class="number">0</span>]||g[i+<span class="number">1</span>][j][<span class="number">0</span>]||(((a[i+<span class="number">1</span>]&gt;&gt;j)&amp;<span class="number">1</span>)==<span class="number">0</span>);</span><br><span class="line">			g[i][j][<span class="number">1</span>]=g[i][j][<span class="number">1</span>]||g[i+<span class="number">1</span>][j][<span class="number">1</span>]||(((a[i+<span class="number">1</span>]&gt;&gt;j)&amp;<span class="number">1</span>)==<span class="number">1</span>);</span><br><span class="line">			<span class="comment">//printf("g[%d][%d][0]=%d,g[%d][%d][1]=%d\n",i,j,g[i][j][0],i,j,g[i][j][1]);</span></span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;=<span class="number">10</span>;j++)&#123;</span><br><span class="line">			f[i][j][<span class="number">0</span>]=f[i][j][<span class="number">0</span>]||g[i][j][<span class="number">0</span>];</span><br><span class="line">			f[i][j][<span class="number">1</span>]=f[i][j][<span class="number">1</span>]||g[i][j][<span class="number">1</span>];</span><br><span class="line">			<span class="comment">//printf("f[%d][%d][0]=%d,f[%d][%d][1]=%d\n",i,j,f[i][j][0],i,j,f[i][j][1]);</span></span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">int</span> w=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=m;i++)&#123;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;=<span class="number">10</span>;j++)&#123;</span><br><span class="line">			<span class="keyword">if</span>(f[p[i]][j][<span class="number">0</span>]==<span class="number">0</span><span class="comment">/*&amp;&amp;f[p[i]][j][1]*/</span>)&#123;</span><br><span class="line">				w+=(<span class="number">1</span>&lt;&lt;j);</span><br><span class="line">				<span class="comment">//printf("&amp;&amp;when i=%d,j=%d,w=%d\n",i,j,w);</span></span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span>(f[p[i]][j][<span class="number">1</span>]==<span class="number">1</span>)&#123;</span><br><span class="line">				w+=(<span class="number">1</span>&lt;&lt;j);</span><br><span class="line">				<span class="comment">//printf("||when i=%d,j=%d,w=%d\n",i,j,w);</span></span><br><span class="line">			&#125;</span><br><span class="line">			<span class="comment">/*if((f[p[i]][j][0]==1)&amp;&amp;(f[p[i]][j][1]==1))&#123;</span></span><br><span class="line"><span class="comment">				w+=(1&lt;&lt;j);</span></span><br><span class="line"><span class="comment">				printf("^^when i=%d,j=%d,w=%d\n",i,j,w);</span></span><br><span class="line"><span class="comment">			&#125;*/</span></span><br><span class="line">		&#125;</span><br><span class="line">		w+=Xor^a[p[i]];</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">cout</span>&lt;&lt;w&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="F"><a href="index.html#F" class="headerlink" title="F"></a>F</h1><p><a href="https://scut.online/p/331" target="_blank" rel="noopener">331. CC看星星</a><br>一个简单又重要的结论：<strong>最大的斜率一定在两个x坐标相邻的点连接产生</strong><br>画图易证。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> N=<span class="number">100005</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">point</span>&#123;</span></span><br><span class="line">	<span class="keyword">int</span> x,y;</span><br><span class="line">&#125;a[N];</span><br><span class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(point x,point y)</span></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> x.x&lt;y.x;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> n;</span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;n);</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">"%d%d"</span>,&amp;a[i].x,&amp;a[i].y);</span><br><span class="line">	&#125;</span><br><span class="line">	sort(a+<span class="number">1</span>,a+<span class="number">1</span>+n,cmp);</span><br><span class="line">	<span class="keyword">double</span> maxk=<span class="number">-1e9</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;n;i++)&#123;</span><br><span class="line">		<span class="keyword">double</span> temp=<span class="keyword">double</span>(a[i].y-a[i+<span class="number">1</span>].y)/(a[i].x-a[i+<span class="number">1</span>].x);</span><br><span class="line">		<span class="keyword">if</span>(temp&gt;maxk)maxk=temp;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">"%.14lf\n"</span>,maxk);</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="G"><a href="index.html#G" class="headerlink" title="G"></a>G</h1><p><a href="https://scut.online/p/332" target="_blank" rel="noopener">332. CC的单向路</a><br>构造题（(⊙o⊙)…）<br>边只能从到达点数多的点连向到达点数少的点。<br>做法参考题解：<br>先按A[i]排序，从小开始，若某个点到达的点数比A值小于它的点数更大，则无解。<br>否则连A[i]条单向边指向前A[i]个点。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">node</span>&#123;</span></span><br><span class="line">	<span class="keyword">int</span> index,reach;</span><br><span class="line">	node(<span class="keyword">int</span> a,<span class="keyword">int</span> b):index(a),reach(b)&#123;&#125;</span><br><span class="line">&#125;;</span><br><span class="line"><span class="class"><span class="keyword">struct</span> <span class="title">edge</span>&#123;</span></span><br><span class="line">	<span class="keyword">int</span> u,v;</span><br><span class="line">	edge(<span class="keyword">int</span> u,<span class="keyword">int</span> v):u(u),v(v)&#123;&#125;</span><br><span class="line">&#125;;</span><br><span class="line"><span class="function"><span class="keyword">bool</span> <span class="title">cmp</span><span class="params">(node x,node y)</span></span>&#123;</span><br><span class="line">	<span class="keyword">return</span> x.reach&lt;y.reach;</span><br><span class="line">&#125;</span><br><span class="line"><span class="built_in">vector</span>&lt;node&gt; G;</span><br><span class="line"><span class="built_in">vector</span>&lt;edge&gt; E;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> n;</span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;n);</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="keyword">int</span> x;</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">"%d"</span>,&amp;x);</span><br><span class="line">		G.push_back(node(i,x));</span><br><span class="line">	&#125;</span><br><span class="line">	sort(G.begin(),G.end(),cmp);</span><br><span class="line">	<span class="keyword">int</span> f=<span class="number">1</span>,m=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;n;i++)&#123;</span><br><span class="line">		<span class="keyword">int</span> order=i;</span><br><span class="line">		<span class="keyword">while</span>(order&gt;<span class="number">0</span>&amp;&amp;G[order].reach==G[order<span class="number">-1</span>].reach)order--;</span><br><span class="line">		<span class="keyword">if</span>(order&lt;G[i].reach)&#123;</span><br><span class="line">			f=<span class="number">0</span>;</span><br><span class="line">			<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;G[i].reach;j++)&#123;</span><br><span class="line">			E.push_back(edge(G[i].index,G[j].index));</span><br><span class="line">			m++;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(f==<span class="number">0</span>)<span class="built_in">puts</span>(<span class="string">"-1"</span>);</span><br><span class="line">	<span class="keyword">else</span>&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">"%d\n"</span>,m);</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">auto</span> i:E)&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">"%d %d\n"</span>,i.u,i.v);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="H"><a href="index.html#H" class="headerlink" title="H"></a>H</h1><p><a href="https://scut.online/p/333" target="_blank" rel="noopener">333. CC的速度</a><br>简单的dp。<br>显然CC的疲劳值先增后减，并且一定会减到0。<br>由于最后的疲劳值一定为0，从后往前分析。<br>0这个状态一定从之前一个0的状态转移而来。<br>故枚举所有可转移的状态，取最优解。<br>利用前缀和计算区间和。<br>f[i]表示在第i分钟结束后，CC的疲劳值一定是0的情况下，最远能冲多远。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> N=<span class="number">10005</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> M=<span class="number">505</span>;</span><br><span class="line"><span class="keyword">int</span> d[N],f[N],sum[N];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> n,m;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;n&gt;&gt;m;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		<span class="built_in">cin</span>&gt;&gt;d[i];</span><br><span class="line">		sum[i]=sum[i<span class="number">-1</span>]+d[i];</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">1</span>;i&lt;=n;i++)&#123;</span><br><span class="line">		f[i]=max(f[i],f[i<span class="number">-1</span>]);</span><br><span class="line">		<span class="keyword">for</span>(<span class="keyword">int</span> j=<span class="number">0</span>;j&lt;=m;j++)&#123;</span><br><span class="line">			<span class="keyword">if</span>(i-(j&lt;&lt;<span class="number">1</span>)&gt;=<span class="number">0</span>)f[i]=max(f[i],f[i-(j&lt;&lt;<span class="number">1</span>)]+sum[i-j]-sum[i-(j&lt;&lt;<span class="number">1</span>)]);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">cout</span>&lt;&lt;f[n]&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="I"><a href="index.html#I" class="headerlink" title="I"></a>I</h1><p><a href="https://scut.online/p/334" target="_blank" rel="noopener">334. CC好厉害</a><br>利用的数学技巧。<br>主要是对数的两个性质：</p>
<script type="math/tex; mode=display">
\log_ab^n=n\log_ab\\
\log_abc=\log_ab+log_ac</script><p>由于任意一个数都可以用科学计数法表示。<br>如$10234432=1.0234432 \times 10^7$，则$\log_{10}(10234432)=\log_{10}(1.0234432)+7$<br>那么$\log_{10}(1.0234432)$就是$\log_{10}(10234432)$的小数部分。<br>因此，若要计算$X^n$的前$k$位，可以先取对数，把指数降成乘积。<br>$\log_{10}X^n=n\times \log_{10}X$，再取出这个数的小数部分$Y$（整数部分不影响前$k$位的值）<br>计算$10^Y$，就可以得到用小数表示的结果。<br>显然$10^{Y+k-1}$的整数部分就是$X^n$的前$k$位。<br>下面用了fmod(X,1)来求X的小数部分。</p>
<figure class="highlight c"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;cmath&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">const</span> <span class="keyword">int</span> M=<span class="number">3</span>;</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="comment">//cout&lt;&lt;fmod(2.71828,1);</span></span><br><span class="line">	<span class="keyword">long</span> <span class="keyword">long</span> n,k;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;n&gt;&gt;k;</span><br><span class="line">	<span class="built_in">cout</span>&lt;&lt;<span class="keyword">int</span>(<span class="built_in">pow</span>(<span class="number">10</span>,M<span class="number">-1</span>+<span class="built_in">fmod</span>(k*<span class="built_in">log10</span>(n),<span class="number">1</span>)))&lt;&lt;<span class="built_in">endl</span>;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="J"><a href="index.html#J" class="headerlink" title="J"></a>J</h1><p><a href="https://scut.online/p/335" target="_blank" rel="noopener">335. CC的金手指</a><br>容易推出ab可以互换位置，而c无法变化。<br>故先判断c的数量，再以c为分界点判断每个区间内的ab数量的奇偶性。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span> <span class="meta-string">&lt;bits/stdc++.h&gt;</span></span></span><br><span class="line"><span class="keyword">using</span> <span class="keyword">namespace</span> <span class="built_in">std</span>;</span><br><span class="line"><span class="keyword">char</span> s1[<span class="number">10005</span>],s2[<span class="number">10005</span>];</span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> n;</span><br><span class="line">	<span class="built_in">cin</span>&gt;&gt;n&gt;&gt;s1&gt;&gt;s2;</span><br><span class="line">	<span class="keyword">int</span> c1=<span class="number">0</span>,c2=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">for</span>(<span class="keyword">int</span> i=<span class="number">0</span>;i&lt;n;i++)&#123;</span><br><span class="line">		<span class="keyword">if</span>(s1[i]==<span class="string">'c'</span>)c1++;</span><br><span class="line">		<span class="keyword">if</span>(s2[i]==<span class="string">'c'</span>)c2++;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(c1!=c2)<span class="built_in">puts</span>(<span class="string">"No"</span>);</span><br><span class="line">	<span class="keyword">else</span>&#123;</span><br><span class="line">		<span class="keyword">int</span> f=<span class="number">1</span>;</span><br><span class="line">		s1[n]=s2[n]=<span class="string">'c'</span>;</span><br><span class="line">		<span class="keyword">int</span> sc1=<span class="number">0</span>,sc2=<span class="number">0</span>;</span><br><span class="line">		<span class="keyword">while</span>(sc1&lt;=n&amp;&amp;sc2&lt;=n)&#123;</span><br><span class="line">			<span class="keyword">int</span> a1=<span class="number">0</span>,a2=<span class="number">0</span>,b1=<span class="number">0</span>,b2=<span class="number">0</span>;</span><br><span class="line">			<span class="keyword">while</span>(s1[sc1]!=<span class="string">'c'</span>)&#123;</span><br><span class="line">				<span class="keyword">if</span>(s1[sc1]==<span class="string">'a'</span>)a1++;</span><br><span class="line">				<span class="keyword">else</span> <span class="keyword">if</span>(s1[sc1]==<span class="string">'b'</span>)b1++;</span><br><span class="line">				sc1++;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">while</span>(s2[sc2]!=<span class="string">'c'</span>)&#123;</span><br><span class="line">				<span class="keyword">if</span>(s2[sc2]==<span class="string">'a'</span>)a2++;</span><br><span class="line">				<span class="keyword">else</span> <span class="keyword">if</span>(s2[sc2]==<span class="string">'b'</span>)b2++;</span><br><span class="line">				sc2++;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">if</span>((a1&amp;<span class="number">1</span>)!=(a2&amp;<span class="number">1</span>)||(b1&amp;<span class="number">1</span>)!=(b2&amp;<span class="number">1</span>))&#123;</span><br><span class="line">				f=<span class="number">0</span>;</span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			sc1++;</span><br><span class="line">			sc2++;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(f)<span class="built_in">puts</span>(<span class="string">"Yes"</span>);</span><br><span class="line">		<span class="keyword">else</span> <span class="built_in">puts</span>(<span class="string">"No"</span>);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="参考资料"><a href="index.html#参考资料" class="headerlink" title="参考资料"></a>参考资料</h1><p>题解<br>优秀代码</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://tootal.xyz/2018/12/01/2018-年计算机科学与工程学院新生赛-1/" data-id="cjptu2lse0000t0tkp0ejpj7g" class="article-share-link">Share</a>
      
      
        <a href="index.html#comments" class="article-comment-link">
          <span class="post-comments-count valine-comment-count" data-xid="/2018/12/01/2018-年计算机科学与工程学院新生赛-1/" itemprop="commentCount"></span>
          Comments
        </a>
      
      
  <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="../../../../tags/ACM/index.html">ACM</a></li></ul>

    </footer>
  </div>
  
    
<nav id="article-nav">
  
    <a href="../软件学院ACM集训队选拔赛第二场/index.html" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Newer</strong>
      <div class="article-nav-title">
        
          软件学院ACM集训队选拔赛第二场
        
      </div>
    </a>
  
  
    <a href="../四种最简真分式的积分/index.html" id="article-nav-older" class="article-nav-link-wrap">
      <strong class="article-nav-caption">Older</strong>
      <div class="article-nav-title">四种最简真分式的积分</div>
    </a>
  
</nav>

  
</article>



  <section id="comments" class="vcomment">

  </section>
</section>
        
          <aside id="sidebar">
  
    

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tags</h3>
    <div class="widget">
      <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/ACM/index.html">ACM</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/C/index.html">C++</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Math/index.html">Math</a></li><li class="tag-list-item"><a class="tag-list-link" href="../../../../tags/Minecraft/index.html">Minecraft</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Tag Cloud</h3>
    <div class="widget tagcloud">
      <a href="../../../../tags/ACM/index.html" style="font-size: 20px;">ACM</a> <a href="../../../../tags/C/index.html" style="font-size: 20px;">C++</a> <a href="../../../../tags/Math/index.html" style="font-size: 15px;">Math</a> <a href="../../../../tags/Minecraft/index.html" style="font-size: 10px;">Minecraft</a>
    </div>
  </div>

  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Archives</h3>
    <div class="widget">
      <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="http://tootal.xyz/archives/2018/12/">December 2018</a></li><li class="archive-list-item"><a class="archive-list-link" href="http://tootal.xyz/archives/2018/11/">November 2018</a></li></ul>
    </div>
  </div>


  
    
  <div class="widget-wrap">
    <h3 class="widget-title">Recent Posts</h3>
    <div class="widget">
      <ul>
        
          <li>
            <a href="../../21/Net-Cloud-Music&#32;List&#32;Download/index.html">Net-Cloud-Music List Download</a>
          </li>
        
          <li>
            <a href="../../21/三角函数和差化积、积化和差公式推导记忆/index.html">三角函数和差化积、积化和差公式推导记忆</a>
          </li>
        
          <li>
            <a href="../../17/《高级语言程序设计C++（一）》样卷/index.html">《高级语言程序设计C++（一）》样卷</a>
          </li>
        
          <li>
            <a href="../../14/Minecraft-Server-Tootal-World/index.html">Minecraft Server Tootal World</a>
          </li>
        
          <li>
            <a href="../../10/2018级计科1、计科2、网工、信安班第15周竞赛题/index.html">2018级计科1、计科2、网工、信安班第15周竞赛题</a>
          </li>
        
      </ul>
    </div>
  </div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy; 2018 tootal<br>
      Powered by <a href="https://hexo.io/" target="_blank">Hexo</a>
    </div>
  </div>
</footer>

    </div>
    <nav id="mobile-nav">
  
    <a href="../../../../index.html" class="mobile-nav-link">Home</a>
  
    <a href="../../../../archives" class="mobile-nav-link">Archives</a>
  
</nav>
    

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>


  <link rel="stylesheet" href="../../../../fancybox/jquery.fancybox.css">
  <script src="../../../../fancybox/jquery.fancybox.pack.js"></script>


<script src="../../../../js/script.js"></script>




  <script src="http://cdn1.lncld.net/static/js/3.0.4/av-min.js"></script>
  <script src="http://unpkg.com/valine/dist/Valine.min.js"></script>
<script>
    var GUEST_INFO = ['nick','mail','link'];
    var guest_info = 'nick,mail,link'.split(',').filter(function(item){
        return GUEST_INFO.indexOf(item) > -1
    });
    var notify = 'false' == true;
    var verify = 'false' == true;
    new Valine({
        el: '.vcomment',
        notify: notify,
        verify: verify,
        appId: "M3v8N5hOEvMyXAbssqMm35dx-gzGzoHsz",
        appKey: "cPadTqnA1Me5mlv0N4Ix96Xl",
        placeholder: "Please leave your footprints.",
        pageSize:'10',
        avatar:'mm',
        lang:'zh-cn'
    });
</script>

  </div>
<script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ["$","$"], ["\\(","\\)"] ],
            skipTags: ['script', 'noscript', 'style', 'textarea', 'pre', 'code'],
            processEscapes: true
        }
    });
    MathJax.Hub.Queue(function() {
        var all = MathJax.Hub.getAllJax();
        for (var i = 0; i < all.length; ++i)
            all[i].SourceElement().parentNode.className += ' has-jax';
    });
</script>
<!--script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"></script>

</body>
</html>